# views.py
from django.shortcuts import render
from .forms import EmailForm

def email_form_view(request):
    if request.method == 'POST':
        # Create a form instance with the submitted data
        form = EmailForm(request.POST)
        if form.is_valid():
            # Process the data
            emails = [email for email in request.POST.getlist('email') if email]
            # Here you can save the emails or perform any other action
            return render(request, 'success.html', {'emails': emails})
    else:
        # Create a blank form instance
        form = EmailForm()
    
    return render(request, 'email_form.html', {'form': form})
